#ifndef DATABASE_DATABASE_H
#define DATABASE_DATABASE_H

#include "Object/Object.hpp"
#include "Paser.hpp"
#include "Excutor.hpp"
#include "Aof.hpp"

#include <optional>
#include <unordered_map>
#include <string>

namespace DBServer
{
namespace Database
{

class DataBase {
public:

    DataBase(int aof_write_buff_size);
    ~DataBase();

    // get the command from server
    // paser command 
    // check
    // excutor
    // return the respond
    std::string run(std::string&&);

private:

    // if the key is not exit, create one 
    // and run excutor
    int check(CommandRequest& req, std::optional<com_func_t>& cft);

    Object* create_key(com_func_t& cft);

private:
    // kv stroge
    std::unordered_map<std::string, Object*> dict;
    // excute the command
    Excutor excutor;
    // paser the command
    Paser paser;
    // aof
    Aof aof;

};

} // namespace DataBase
} // namespace DBServer




#endif